package com.baturu.vin.dfpv.dal.dao;

import com.baturu.vin.dfpv.dto.DfpvCarSystemBtrIdDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: chenjiahao
 * @Time: 2018/9/5
 */
public interface DfpvCarSystemBtrIdDAO {

    @Select({"SELECT btrId,carSystem,engineType, transmission ",
            "FROM dfpv_cartype_btrid",
            "WHERE carSystem = #{carSystem}",
            "AND engineType = #{engineType}",
            "AND transmission= #{transmission}"})
    List<DfpvCarSystemBtrIdDTO> queryCarSystemByVinResult(@Param("carSystem") String carSystem,@Param("engineType") String engineType,@Param("transmission") String transmission);

    @Insert({"INSERT INTO dfpv_cartype_btrid (",
            "btrId,",
            "carSystem,",
            "engineType,",
            "transmission,",
            "year",
            ") values (",
            "#{dto.btrId},",
            "#{dto.carSystem},",
            "#{dto.engineType},",
            "#{dto.transmission},",
            "#{dto.year})"})
    @Options(useGeneratedKeys = true, keyProperty = "dto.btrId")
    int insertCarSystemBtrId(@Param("dto") DfpvCarSystemBtrIdDTO dfpvCarSystemBtrIdDTO);

    @Select("SELECT * FROM dfpv_cartype_btrid")
    List<DfpvCarSystemBtrIdDTO> fix ();
}
